package com.atlzk.group.tgou.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.atlzk.group.tgou.entity.MiaoShopEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.atlzk.group.tgou.entity.MiaoDateEntity;
import com.atlzk.group.tgou.service.MiaoDateService;
import com.atlzk.common.utils.PageUtils;
import com.atlzk.common.utils.R;



/**
 * 
 *
 * @author liuzekun
 * @email 2803587841@gmail.com
 * @date 2021-06-29 09:58:59
 */
@RestController
@RequestMapping("tgou/miaodate")
//@CrossOrigin
public class MiaoDateController {
    @Autowired
    private MiaoDateService miaoDateService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("tgou:miaodate:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = miaoDateService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{smsMdateId}")
    //@RequiresPermissions("tgou:miaodate:info")
    public R info(@PathVariable("smsMdateId") Long smsMdateId){
		MiaoDateEntity miaoDate = miaoDateService.getById(smsMdateId);

        return R.ok().put("miaoDate", miaoDate);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("tgou:miaodate:save")
    public R save(@RequestBody MiaoDateEntity miaoDate){
		miaoDateService.save(miaoDate);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("tgou:miaodate:update")
    public R update(@RequestBody MiaoDateEntity miaoDate){
		miaoDateService.updateById(miaoDate);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("tgou:miaodate:delete")
    public R delete(@RequestBody Long[] smsMdateIds){
		miaoDateService.removeByIds(Arrays.asList(smsMdateIds));

        return R.ok();
    }

    /**
     * 信息
     */
    @RequestMapping("/byMdate/{smsMdateId}")
    //@RequiresPermissions("tgou:miaodate:info")
    public R byMdate(@PathVariable("smsMdateId") Long smsMdateId){
        List <MiaoShopEntity> miaoShopEntityList = miaoDateService.byMdate(smsMdateId);
        return R.ok().put("miaoShopEntityList", miaoShopEntityList);
    }

}
